00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00048 #ifndef GL2D_H_INCLUDED
00049 #define GL2D_H_INCLUDED
00050
00051 #include <stdio.h>
00052 #include <math.h>
00053 #include <string.h>
00054
00055 #include <libraries/include/GL/glfw.h>
00056
00057
00058
00059 #define ARGB_A(u) (((u) >> 24) & 0x000000FF)
00060 #define ARGB_R(u) (((u) >> 16) & 0x000000FF)
00061 #define ARGB_G(u) (((u) >> 8) & 0x000000FF)
00062 #define ARGB_B(u) (((u) >> 0) & 0x000000FF)
00063 #define RGBA( r, g, b, a ) ((a) << 24 | (r) << 16 | (g) << 8 | (b) )
00064
00071 #define GL2D_RGBA( r, g, b, a ) RGBA( b, g, r, a)
00072
00073 #ifndef true
00074 #define true 1
00075 #define false 0
00076 #endif
00077
00078
00079
00080
00081
00082
00083
00103 typedef enum GL2D_FLIP_MODE
00104 {
00105
00106 GL2D_FLIP_NONE = 1 << 0,
00107 GL2D_FLIP_V = 1 << 1,
00108 GL2D_FLIP_H = 1 << 2
00109
00110 } GL2D_FLIP_MODE;
00111
00112
00117 typedef enum GL2D_BLEND_MODE
00118 {
00119
00120 GL2D_TRANS = 0,
00121 GL2D_SOLID,
00122 GL2D_BLENDED,
00123 GL2D_GLOW,
00124 GL2D_ALPHA,
00125 GL2D_BLACK
00128 } GL2D_BLEND_MODE;
00129
00153 typedef struct glImage
00154 {
00155
00156 int width;
00157 int height;
00158 float u_off;
00159 float v_off;
00160 float u_width;
00161 float v_height;
00163 GLuint textureID;
00165 } glImage;
00166
00167
00168 #ifdef __cplusplus
00169 extern "C"
00170 {
00171 #endif
00172
00178 void glBegin2D( const int width, const int height );
00179
00180
00184 void glEnd2D();
00185
00191 void glScreen2D( const int width, const int height, const int mode );
00192
00200 void glScreen2DEx( const int width, const int height, const int mode,
00201 const int depthbits, const int stencilbits );
00202
00205 void glClose();
00206
00210 void glBlendMode( const GL2D_BLEND_MODE mode );
00211
00221 void glEnableSpriteStencil( const GLuint gl2dcolor, const GLuint gl2dcolor_env, int flag );
00222
00226 void glEnableAntialias( int flag );
00227
00229 void glClearScreen();
00230
00237 void glLineGlow( const int x1, const int y1,
00238 const int x2, const int y2,
00239 const int width, const GLuint color );
00240
00246 void glPutPixel( int x, int y, const GLuint color );
00247
00253 void glLine( int x1, int y1, int x2, int y2, const GLuint color );
00254
00261 void glLineGradient( int x1, int y1, int x2, int y2,
00262 const GLuint color1, const GLuint color2 );
00263
00269 void glBox( int x1, int y1, int x2, int y2, const GLuint color );
00270
00276 void glBoxFilled( int x1, int y1, int x2, int y2, const GLuint color );
00277
00286 void glBoxFilledGradient( int x1, int y1, int x2, int y2,
00287 const GLuint color1, const GLuint color2,
00288 const GLuint color3, const GLuint color4 );
00289
00296 void glTriangle( int x1, int y1, int x2, int y2, int x3, int y3, const GLuint color );
00297
00304 void glTriangleFilled( int x1, int y1, int x2, int y2, int x3, int y3, const GLuint color );
00305
00314 void glTriangleFilledGradient( int x1, int y1, int x2, int y2, int x3, int y3,
00315 const GLuint color1, const GLuint color2, const GLuint color3 );
00316
00324 void glEllipse( int x, int y, int a, int b, int degrees, const GLuint color );
00325
00333 void glEllipseFilled( int x, int y, int a, int b, int degrees, const GLuint color );
00334
00335
00336
00337
00344 void glSprite( const int x, const int y, const int flipmode, const glImage *spr );
00345
00353 void glSpriteScale( const int x, const int y, const float scale, const int flipmode, const glImage *spr );
00354
00363 void glSpriteScaleXY( const int x, const int y, const float scaleX, const float scaleY, const int flipmode, const glImage *spr );
00364
00372 void glSpriteRotate( const int x, const int y, const int angle, const int flipmode, const glImage *spr );
00373
00374
00383 void glSpriteRotateScale( const int x, const int y, const int angle, const float scale, const int flipmode, const glImage *spr );
00384
00385
00395 void glSpriteRotateScaleXY( const int x, const int y, const int angle, const float scaleX, const float scaleY, const int flipmode, const glImage *spr );
00396
00397
00408 void glSpriteOnQuad( int x1, int y1,
00409 int x2, int y2,
00410 int x3, int y3,
00411 int x4, int y4,
00412 float uoff, float voff,
00413 int flipmode, const glImage *spr );
00414
00415
00427 void glSpriteOnQuadClipped( int x1, int y1,
00428 int x2, int y2,
00429 int x3, int y3,
00430 int x4, int y4,
00431 float luclip, float lvclip,
00432 float ruclip, float rvclip,
00433 int flipmode, const glImage *spr );
00434
00435
00442 void glSpriteStretchHorizontal( int x, int y, int length, const glImage *spr );
00443
00444
00451 void glSpriteStretchVertical( int x, int y, int height, const glImage *spr );
00452
00460 void glSpriteStretchHV( int x, int y, int length, int height, const glImage *spr );
00461
00469 void glPrint( int x, int y, const char *text, const GLuint color );
00470
00481 GLuint glLoadSpriteSet( const char *filename,
00482 glImage *sprite,
00483 const int width,
00484 const int height,
00485 const int numframes,
00486 const unsigned int *texcoords,
00487 const GLuint filtermode );
00488
00489
00500 GLuint glLoadTileSet( const char *filename,
00501 glImage *sprite,
00502 const int tile_wid,
00503 const int tile_hei,
00504 const int bmp_wid,
00505 const int bmp_hei,
00506 const GLuint filtermode );
00507
00515 GLuint glLoadSprite( const char *filename,
00516 glImage *sprite,
00517 const int width,
00518 const int height,
00519 const GLuint filtermode );
00520
00521
00528 void glGet( glImage *SpriteDest, const glImage *SpriteSource, int x1, int y1, int x2, int y2 );
00529
00530 #ifdef __cplusplus
00531 }
00532 #endif
00533
00534
00535 #endif // GL2D_H_INCLUDED